<html>
<head>
<title>Facebook / Maps Mashup</title>
<style type="text/css">
      @import url("http://www.google.com/uds/css/gsearch.css");
      @import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
</style>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAYgIFcdB73ikjsshF47qFhRT9MMXG_tYPVLibiAtjK-zmIeBb9RTQy57sFP4wbxEGLiuFm3mV7BVEKQ" type="text/javascript"></script>
<script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0" type="text/javascript"></script>
<script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js" type="text/javascript"></script>
<script type="text/javascript">
	var points;
	var parser;
	var map;
	google.load("gdata", "1");
      function initialize() {
        if (GBrowserIsCompatible()) {
		/////////////////////////// load calendar
		  google.gdata.client.init(handleGDError);
		  loadCalendarByAddress('connor.imes@gmail.com');
		///////////////////////////
		
          // Create and Center a Map
          map = new GMap2(document.getElementById("map_canvas"));
			var over = new GGeoXml("http://teamname.gan.tjohns.net/google/campus.kml");
          map.setCenter(new GLatLng(40, -95), 4);
          map.addControl(new GLargeMapControl());
          map.addControl(new GMapTypeControl());
		map.addOverlay(over);
          map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));

	// Code to parse the kml file on our own	
		if (window.ActiveXObject) {
  			parser=new ActiveXObject("Microsoft.XMLDOM");
  			parser.async=false;
  			parser.load("/google/campus.kml");
  		}
		// code for Mozilla, Firefox, Opera, etc.
		else if (document.implementation && document.implementation.createDocument) {
        		parser = new XMLHttpRequest();
			parser.open( "GET", "/google/campus.kml", false );
			parser.send(null);
		 	parser = parser.responseXML;
  		}
		else {
  			alert('Your browser cannot handle this script');
  		}
	// End kml parse code
	var add_to_names="";
	var points = parser.getElementsByTagName( "name" );
		for (i=0;i<points.length;i++) {
			add_to_names +="<a href = \"#\" onmouseup= 'zoomOnFriend(\""+i+"\")'>";
			add_to_names +=points.item(i).firstChild.nodeValue+"</a>, ";
		}
	
		document.getElementById("friend_names").innerHTML=add_to_names;	
        }
      }

	function zoomOnFriend(mystring) {
		document.getElementById("test").innerHTML=mystring;
		var coords = parser.getElementsByTagName( "coordinates" );
		var mycoords = coords.item(mystring).firstChild.nodeValue.split(",");

		var descs = parser.getElementsByTagName( "description" );
		
		var point = new GLatLng(mycoords[1], mycoords[0]);
		map.setZoom(15);
		map.setCenter(point);
 		map.openInfoWindow(point, descs.item(mystring).firstChild.nodeValue);
	}

      GSearch.setOnLoadCallback(initialize);
    </script>
<script type="text/javascript" language="JavaScript" src="calendar_integrate.js"></script>
<link href="p24-2008.css" rel="stylesheet" type="text/css">
</head>
<body onload="initialize()" onunload="GUnload()">
<div class="title"><img src="logo.jpg" width="400" height="30"></div>
<div id="outer"> 
  <table id="container">
    <tr valign="top" align="center"> 
      <td> <table width="950" align="center" id="mainTable">
          <tr valign="top"> 
            <td width="700"><div class="mapRegion" id="map_canvas" style="width: 700px; height: 500px"></div></td>
            <td width="250" class="mapRegion"><div id="calendarTitle"></div>
              <div id="events"></div></td>
          </tr>
          <tr> 
            <td colspan="2" class="dataRegion">Your friends:<br>
              <div id="friend_names"></div></td>
          </tr>
        </table></td>
    </tr>
  </table>
</div>
<div id="footer">&quot;Team Name&quot;: Paul Kamp III, Paul Pham, Connor Imes, 
  & Andrew Emmons <br>
  Released under GPLv3 for the USC Google All Nighter - February 17-18, 2008.</div>
<div id = "test"></div>
</body>
</html>
